#pragma once

#include <QHBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QStringList>
#include <QLineEdit>
#include <QPushButton>
#include <QProgressBar>
#include <QGroupBox>
#include <QLineEdit>
#include <QLabel>
#include <QEvent>
#include "BotCombats.h"

enum EventID
{
    EMPTY_FIELDS,
    PIXMAP,
    ERROR_STRIKES,
    SET_VALUE
};

class CWorkerEvent : public QEvent
{
public:
  CWorkerEvent(int EventId) : QEvent(QEvent::User), m_EventId(EventId)
  {
  };

 ~CWorkerEvent()
 {
 }

public:
    int GetId() const
    {
        return m_EventId;
    }

    QPixmap & GetPixmap()
    {
        return m_Pix;
    }

    void SetPixmap(QPixmap &Pix)
    {
        m_Pix = Pix;
    }

    void SetStrikes(STRIKES_ENTRY &Strikes)
    {
        memcpy(&m_Strikes, &Strikes, sizeof(STRIKES_ENTRY));
    }

    STRIKES_ENTRY & GetStrikes()
    {
        return m_Strikes;
    }

private:
    int             m_EventId;
    QPixmap         m_Pix;
    STRIKES_ENTRY   m_Strikes;
};

class CMainWindow : public QWidget
{
	Q_OBJECT

private:
	QHBoxLayout			*m_HTabLayout;
	QTabWidget			*m_Tab;
	QWidget				*m_MainPicture;
	QLineEdit			*m_NickEdit;
	QPushButton			*m_AnalyzeButton;

	QGroupBox           *m_StrikeGroupBox;
	QGroupBox			*m_CredentialsGroupBox;

    QLineEdit           *m_PswLine;
    QLineEdit           *m_LoginLine;

	QProgressBar		*m_HeadSProgress;
	QProgressBar		*m_ChestSProgress;
	QProgressBar		*m_GroinSProgress;
	QProgressBar		*m_LegsSProgress;

    QLabel              *m_HeadLabel;
    QLabel              *m_ChestLabel;
    QLabel              *m_GroinLabel;
    QLabel              *m_LegsLabel;

    QLabel              *m_LoginLabel;
    QLabel              *m_PswLabel;

	QStringList			 m_TabStrList;
    
    CBotCombats         *m_Bot;

private:
    bool event(QEvent* Event);

public:
    QLineEdit * GetNickEdit() const;
    QLineEdit * GetLoginLine() const;
    QLineEdit * GetPswLine() const;

    void SetLabelVisible(bool Visible);
    void SetStrikesValue(STRIKES_ENTRY &Strikes);

public slots:
	void OnAnalyzeClick();

public:
	CMainWindow();
	~CMainWindow();
};

class CBotWorker : public QObject 
{
    Q_OBJECT

public:
    CBotWorker(CMainWindow *MainWindow);
    virtual ~CBotWorker();

private:
    CBotCombats             *m_Bot;
    CMainWindow             *m_MainWindow;
    
public slots:
    void Process();
 
signals:
    void finished();
};